package com.asiainfo.dacp.datastash.worker.executor.adapter.datax;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import com.asiainfo.dacp.datastash.worker.executor.adapter.datax.utils.CommonErrorCode;
import com.asiainfo.dacp.datastash.worker.executor.adapter.datax.utils.WorkerException;
import com.google.common.io.Files;

public class DpTranslater {

	public static String buildTemplate(String engine) {
		String jobResource = DataxTranslater.class.getClassLoader().getResource(".").getFile();
		jobResource = jobResource + File.separator +engine+ File.separator + "template.json";
		String readFileToString;
		try {
			readFileToString = Files.toString(new File(jobResource), Charset.defaultCharset());
		} catch (IOException e) {
			throw WorkerException.asDataXException(CommonErrorCode.CONFIG_ERROR, "获取作业配置信息失败:" + jobResource, e);
		}
		return readFileToString;
	}

}
